/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-01-17     Wangjiangbo       the first version
 */

#include "mod/mod_cia402dev.h"
#include "mod/mod_canopen.h"

bool cia402_switch_on(int8_t id)
{
    mod_canopen_write_sdo(id, 0x604000, WRITE_REQ_BYTE_2, 7);
}

bool cia402_enable(int8_t id)
{
    mod_canopen_write_sdo(id, 0x604000, WRITE_REQ_BYTE_2, 0x0f);
}

bool cia402_disable(int8_t id)
{
    mod_canopen_write_sdo(id, 0x604000, WRITE_REQ_BYTE_2, 6);
}

bool cia402_set_mode(int8_t id, uint8_t mode)
{
    mod_canopen_write_sdo(id, 0x606000, WRITE_REQ_BYTE_1, mode);
}

bool cia402_set_vel(int8_t id, int32_t vel)
{
    mod_canopen_write_sdo(id, 0x60FF00, WRITE_REQ_BYTE_4, vel);
}

bool cia402_set_output(int8_t id, uint16_t value)
{
    mod_canopen_write_sdo(id, 0x219400, WRITE_REQ_BYTE_2, value);
}
